<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page session="false" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<jsp:include page="/WEB-INF/views/common/header.jsp" />

<link rel="stylesheet" href="<c:out value="${pageContext.request.contextPath}"/>/resources/common/bootstrap/css/bootstrap-datepicker.min.css">

<script type="text/javascript" src="<c:out value="${pageContext.request.contextPath}"/>/resources/js/customer_popup.js"></script>
<script type="text/javascript" src="<c:out value="${pageContext.request.contextPath}"/>/resources/js/project_div_popup.js"></script>
<script type="text/javascript" src="<c:out value="${pageContext.request.contextPath}"/>/resources/common/bootstrap/js/bootstrap-datepicker.min.js"></script>

<script type="text/javascript">
	$(document).ready(function() {
		var firstdate;
		
		var startdate = $('#accept_start_date').datepicker({
			format: "yyyy-mm-dd",
			autoclose: true,
			todayHighlight: true
		}).on('changeDate', function(ev) {
			firstdate = ev.date.valueOf();
		});
		
		$('#accept_end_date').datepicker({
			format: "yyyy-mm-dd",
			autoclose: true,
			todayHighlight: true,
		});
	});
	
	function recordRetrieve() {
		var acceptStartDate 	= $('#start_date').val();
		var acceptEndDate 		= $('#end_date').val();
		var customerCode		= $('#customer_code').val();
		var operatorCode 		= $('#operator_code').val();
		var repairCenterCode 	= $('#repair_center_code').val();
		var serialNo			= $('#serial_no').val();
		var replaceSerialNo 	= $('#replace_serial_no').val();
		var projectCode 		= $('#project_code').val();
		
		if ( acceptStartDate == null || acceptStartDate.trim().length == 0 
				|| acceptEndDate == null || acceptEndDate.trim().length == 0 ) {
			alert("접수일 값은 필수입니다.");
			return;
		}
		
		$.ajax({
			url:"repair_record_list/list",
			data:{acceptStartDate:acceptStartDate, acceptEndDate:acceptEndDate, customerCode:customerCode, operatorCode:operatorCode,
				repairCenterCode:repairCenterCode, serialNo:serialNo, replaceSerialNo:replaceSerialNo, projectCode:projectCode},
			type:'GET',
			dataType:'json'
		}).done(function(data) {
			$('#repair_record_table').bootstrapTable('load', data);
		});
	};
	
</script>

</head>
<body>
	<jsp:include page="/WEB-INF/views/main/menu.jsp" />

	<div class="container">
		<div class="page-header">
			<h3>수리실적 List</h3>
		</div>
		<form class="form-inline">
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group form-group-sm">
						<label class="control-label" for="accept_date" style="width: 100px">접수일</label> 
						<div class="input-group date" id="accept_start_date">
  							<input type="text" class="form-control" size="7" disabled="disabled" id="start_date">
  								<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
						</div>
						<label class="control-label" for="release_term" style="width: 90px; text-align:center;">~</label> 
						<div class="input-group date" id="accept_end_date">
  							<input type="text" class="form-control" size="7" disabled="disabled" id="end_date">
  								<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group form-group-sm">
						<label class="control-label" for="serial_no" style="width: 100px">Serial No.</label> 
						<input type="text" class="form-control" id="serial_no" size="59">
					</div>
				</div>
			</div>
			<p />
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group form-group-sm">
						<label class="control-label" for="customer_code" style="width: 100px">고객</label> 
						<input type="text" class="form-control" id="customer_code" placeholder="고객 코드" disabled>
						<div class="input-group">
							<label class="sr-only" for="customer_name">고객명</label> 
							<input type="text" class="form-control" id="customer_name" placeholder="고객 명" disabled> 
							<span class="input-group-btn">
								<input type="button" class="btn btn-primary btn-sm" id="customer_btn" value="선택"/>
							</span>							
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group form-group-sm">
						<label class="control-label" for="replace_serial_no" style="width: 100px">대체 Serial No.</label> 
						<input type="text" class="form-control" id="replace_serial_no" size="59">
					</div>
				</div>
			</div>
			<p />
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group form-group-sm">
						<label class="control-label" for="operator_code" style="width: 100px">운용국</label> 
						<input type="text" class="form-control" id="operator_code" placeholder="운용국 코드" disabled>
						<div class="input-group">
							<label class="sr-only" for="operator_name">운용국 명</label> 
							<input type="text" class="form-control" id="operator_name" placeholder="운용국 명" disabled> 
							<span class="input-group-btn">
								<input type="button" class="btn btn-primary btn-sm" id="operator_btn" value="선택"/>
							</span>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group form-group-sm">
						<label class="control-label" for="project_div" style="width: 100px">프로젝트구분</label> 
						<input type="text" class="form-control" id="project_code" placeholder="프로젝트 코드" disabled>
						<div class="input-group">
							<input type="text" class="form-control" id="project_name" placeholder="프로젝트 명" disabled> 
							<span class="input-group-btn"> 
								<input type="button" class="btn btn-primary btn-sm" id="project_div_btn" value="선택" />
							</span>
						</div>
					</div>
				</div>
			</div>
			<p />
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group form-group-sm">
						<label class="control-label" for="repair_center" style="width: 100px">수리처</label> 
						<input type="text" class="form-control" id="repair_center_code" placeholder="수리처 코드" disabled>
						<div class="input-group">
							<input type="text" class="form-control" id="repair_center_name" placeholder="수리처 명" disabled> 
							<span class="input-group-btn"> 
								<input type="button" class="btn btn-primary btn-sm" id="repair_center_btn" value="선택" />
							</span>
						</div>
					</div>
				</div>
				<div class="col-sm-offset-4 col-sm-2">
					<input type="button" class="btn btn-primary btn-sm btn-block" id="record_retrieve_btn" value="조회" onclick="recordRetrieve()">
				</div>
			</div>
		</form>
		<p />
		<table id="repair_record_table" data-toggle="table" data-height="400" data-pagination="true" data-search="false">
			<thead>
				<tr>
					<th data-field="state" data-checkbox="true"></th>
					<th data-field="rowNum" data-align="center">No</th>
					<th data-field="custName" data-align="center">고객</th>
					<th data-field="projectType" data-align="center">프로젝트</th>
					<th data-field="shipCustName" data-align="center">운용국</th>
					<th data-field="modelName" data-align="center">기종명</th>
					<th data-field="itemCode" data-align="center">제품코드</th>
					<th data-field="itemName" data-align="center">제품명</th>
					<th data-field="serialNo" data-align="center">Serial No.</th>
					<th data-field="mfgDate" data-align="center">제조일자</th>
					<th data-field="shippingDate" data-align="center">POP출하일</th>
					<th data-field="repairCnt" data-align="center">수리차수</th>
					<th data-field="reworkSeq" data-align="center">재수리 차수</th>
					<th data-field="revision" data-align="center">REVISION</th>
					<th data-field="custWarranty" data-align="center">고객 Warranty</th>
					<th data-field="custBillableCheck" data-align="center">고객청구 여부</th>
					<th data-field="maintenanceCheck" data-align="center">유지보수 계약</th>
					<th data-field="unitCostContract" data-align="center">단가 계약</th>
					<th data-field="custEstimated" data-align="center">고객 견적</th>
					<th data-field="repairCenterEstimated" data-align="center">수리처 견적</th>
					<th data-field="repairType" data-align="center">수리유형</th>
					<th data-field="lastComplateDate" data-align="center">이전인계일</th>
					<th data-field="requestDate" data-align="center">접수일자</th>
					<th data-field="deliveryDate" data-align="center">수리요청출고일</th>
					<th data-field="repairCenterStoredDate" data-align="center">수리처입고확인</th>
					<th data-field="repairCenterDeliveryDate" data-align="center">수리처완료출고</th>
					<th data-field="completeStoredDate" data-align="center">완료품입고처리</th>
					<th data-field="actionDate" data-align="center">조치일</th>
					<th data-field="lastCustCunfirmDate" data-align="center">인계일</th>
					<th data-field="dueDate" data-align="center">납기일</th>
					<th data-field="repairCenter" data-align="center">수리처</th>
					<th data-field="custReplaceItemCode" data-align="center">고객대체제품코드</th>
					<th data-field="custReplaceSerialNo" data-align="center">고객대체 S/N</th>
					<th data-field="defectReason" data-align="center">불량원인</th>
					<th data-field="faultDetails" data-align="center">불량내역</th>
					<th data-field="repairResult" data-align="center">수리내역</th>
					<th data-field="baseStation" data-align="center">기지국정보</th>
					<th data-field="custRequestNo" data-align="center">고객의뢰번호</th>
					<th data-field="custSerialNo" data-align="center">고객 Serial No</th>
					<th data-field="repairSummary" data-align="center">수리내용</th>
				</tr>
			</thead>
		</table>
	</div>
	<div class="modal fade" role="dialog" id="modal_div">
		<div class="modal-dialog">
			<div class="modal-content"></div>
		</div>
	</div>
</body>
</html>